#ifndef ITEMEDITMODEL_H
#define ITEMEDITMODEL_H


#include "data_global.h"
#include "item.h"


#include <QAbstractItemModel>


class DATASHARED_EXPORT ItemEditModel : public QAbstractItemModel
{
    Q_OBJECT

public:

    enum Field
    {
        Field_FIRST = 0,
        Field_NAME = Field_FIRST,
        Field_VALUE,
        Field_LAST = Field_VALUE
    };

    explicit ItemEditModel(QObject *parent = 0);
    explicit ItemEditModel(Item* item, QObject *parent = 0);

    void setItem(Item* item);
    Item* item() const;

    virtual QModelIndex index(int row, int column, const QModelIndex &parent) const;
    virtual QModelIndex parent(const QModelIndex &child) const;

    virtual int rowCount(const QModelIndex &parent) const;
    virtual int columnCount(const QModelIndex &parent) const;

    virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
    virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);

    virtual Qt::ItemFlags flags(const QModelIndex &index) const;

    virtual QModelIndex buddy(const QModelIndex &index) const;

    
protected:

    QVariant nameData(const QModelIndex& index, int role) const;
    QVariant valueData(const QModelIndex& index, int role) const;


private:

    ItemPtr m_item;
    
};

#endif // ITEMEDITMODEL_H
